package com.moxing.admin.controller;


import com.moxing.admin.common.entity.Order;
import com.moxing.admin.service.OrderService;
import com.moxing.admin.common.dto.RestResponseDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "/api/order",description = "订单管理")
@RestController
@RequestMapping("/api/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 测试本地服务
     * @return
     */
    @ApiOperation(value = "查询所有订单(Mysql库)",httpMethod = "GET")
    @GetMapping("/getOrderMysqlList")
    @ResponseBody
    public RestResponseDTO getOrderMysqlList() {
        return RestResponseDTO.success(orderService.getOrderMysql());
    }

    @ApiOperation(value = "查询所有订单(Oracle库)",httpMethod = "GET")
    @GetMapping("/getOrderOracleList")
    @ResponseBody
    public RestResponseDTO getOrderOracleList() {
        return RestResponseDTO.success(orderService.getOrderOracle());
    }

    @ApiOperation(value = "根据id查询订单，oracle库",httpMethod = "GET")
    @GetMapping("/getOrderById")
    @ResponseBody
    public RestResponseDTO getOrderById(@RequestParam String id) {
        return RestResponseDTO.success(orderService.getOrderById(id));
    }

    @ApiOperation(value = "根据id查询订单，redis",httpMethod = "GET")
    @GetMapping("/getOrderByRedis")
    @ResponseBody
    public RestResponseDTO getOrderByRedis(@RequestParam String id) {
        return RestResponseDTO.success(orderService.getOrderByRedis(id));
    }
}
